#coding: utf-8
class CulturalHeritage::Researcher < ActiveRecord::Base
  belongs_to :obj_user, :class_name => 'User',  :foreign_key => 'user'
  default_scope where("deleted = 0")

  def self.count_cultural_heritage_dependencies(id)
      return find(:all,:conditions=>["cultural_heritage_researchers.cultural_heritage = ? and (cultural_heritage_researchers.deleted = ?) ",id,0],:select=>"count(*) as 'researchers'")[0].researchers.to_i
  end

  def self.count_user_dependencies(id)
      return find(:all,:conditions=>["cultural_heritage_researchers.user = ? and (cultural_heritage_researchers.deleted = ?) ",id,0],:select=>"count(*) as 'researchers'")[0].researchers.to_i
  end
end
